#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void Asc_sort(int* arr, int x)
{

    int i = 0;
    int tmp = 0;
    int left = 0;
    int right = 1;
    while (1)
    {
        while (right < x)
        {
            if (arr[left] > arr[right])
            {
                tmp = arr[left];
                arr[left++] = arr[right];
                arr[right++] = tmp;
            }
        }
        int count = 0;
        for (i = 0; i < x; i++)
        {
            if (arr[i] <= arr[i + 1])
            {
                count++;
            }
        }
        if (count == x - 1)
            break;
    }

}
int main() {
    int arr1[1000] = { 0 };
    int arr2[1000] = { 0 };
    int arr3[2000] = { 0 };
    int n = 0;
    int m = 0;
    scanf("%d %d", &n, &m);
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d ", &arr1[i]);
        arr3[i] = arr1[i];

    }
    for (i = 0; i < m; i++)
    {
        scanf("%d ", &arr2[i]);
        arr3[i + n] = arr2[i];
    }
    Asc_sort(arr3, n + m);

    for (i = 0; i < n + m; i++)
    {
        printf("%d ", arr3[i]);
    }


    return 0;
}